$(function () {
    //x轴维度
    var xName = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"];
    //数据入库情况
    function loadChartDataEntry() {
        var valueD = [
            /*[2000, 1000, 499, 3210, 3456, 4560, 2035, 3049, 6000, 5302, 4500, 3456],*/
            [2834, 2345, 3267, 3500, 5767, 7245, 5083, 4234, 3345, 4888, 3200, 3000],
            [2245, 2045, 2345, 2354, 5632, 6832, 4232, 3456, 3235, 4523, 3000, 2500],
            [589, 300, 922, 1146, 135, 413, 851, 778, 110, 365, 200, 500]
        ];
        var chart = echarts.init(document.getElementById('data_entry'));
        chart.setOption({
            color: ['#4472C4', '#ED7D31', '#A5A5A5', '#FFC000', '#5B9BD5'],
            backgroundColor: '#fff',
            title: {
                text: '数据入库情况',
                x: 'center',
                y: 'bottom',
                textStyle: {
                    fontWeight: 'normal',
                    fontSize: 14,
                    fontFamily: 'cursive',
                    color: '#000'
                }
            },
            legend: {
                data: [{
                    name: '上传总数'
                }, {
                    name: '入库成功总数'
                }, {
                    name: '失败总数'
                }]
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '40',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                data: xName,
                axisLabel: {
                    rotate: 15
                }
            }],
            yAxis: [{
                type: 'value',
                axisLabel: {
                    formatter: function (value, index) {
                        var text = value / 1000 + "k";
                        return text;
                    }
                }
            }],
            series: [{
                name: '上传总数',
                type: 'line',
                data: valueD[0],
            }, {
                name: '入库成功总数',
                type: 'line',
                data: valueD[1],
            }, {
                name: '失败总数',
                type: 'line',
                data: valueD[2],
            }]
        });
    };
    //待稽核问题数据
    function loadChartCheck() {
        var valueD = [
            /*[283, 123, 500, 1234, 4567, 7456, 5392, 5321, 4567, 2385, 1245, 2452],*/
            [2834, 2345, 1267, 1500, 567, 1245, 583, 1234, 2345, 1888, 1200, 1000],
            [1245, 2045, 2345, 2354, 5632, 6832, 4232, 3456, 3235, 4523, 3000, 2500],
            [0, 712, 1794, 4563, 3522, 5633, 5687, 7323, 4952, 5673, 6783, 5234]
        ];
        var chart = echarts.init(document.getElementById('wait_check'));
        chart.setOption({
            color: ['#4472C4', '#ED7D31', '#A5A5A5', '#FFC000', '#5B9BD5'],
            backgroundColor: '#fff',
            title: {
                text: '待稽核问题数据变化趋势',
                x: 'center',
                y: 'bottom',
                textStyle: {
                    fontWeight: 'normal',
                    fontSize: 14,
                    fontFamily: 'cursive',
                    color: '#000'
                }
            },
            legend: {
                data: [{
                    name: '重复领待'
                }, {
                    name: '重复参保'
                }, {
                    name: '生存状态异常'
                }]
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '40',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                data: xName,
                axisLabel: {
                    rotate: 15
                }
            }],
            yAxis: [{
                type: 'value',
                axisLabel: {
                    formatter: function (value, index) {
                        var text = value / 1000 + "k";
                        return text;
                    }
                }
            }],
            series: [{
                name: '重复领待',
                type: 'line',
                data: valueD[0],
            }, {
                name: '重复参保',
                type: 'line',
                data: valueD[1],
            }, {
                name: '生存状态异常',
                type: 'line',
                data: valueD[2],
            }]
        });
    };


    //公告栏轮播
    var $this = $(".main-attention");
    var scrollTimer;
    $this.hover(function () {
        clearInterval(scrollTimer);
    }, function () {
        scrollTimer = setInterval(function () {
            scrollNews($this);
        }, 2000);
    }).trigger("mouseout");
    function scrollNews(obj) {
        var $self = obj.find("ul:first");
        var lineHeight = $self.find("li:first").height();
        $self.animate({"margin-top": -lineHeight + "px"}, 800, function () {
            $self.css({"margin-top": "0px"}).find("li:first").appendTo($self);
        })
    }

    //初始页面
    function init() {
        loadChartDataEntry();
        loadChartCheck();
    };
    init();
});